{extend name='Public:content'/}
{block name='title'}后台菜单管理{/block}
{block name='content'}
<div class="row animated fadeIn">
    <div class="row">
        <div class="col-md-10">
            <div class="panel panel-default tabs">
                <ul class="nav nav-tabs" role="tablist">
                    <li class="{$menuChild?:'active'}"><a href="#tab-first" role="tab" data-toggle="tab">菜单列表
                        <button class="btn btn-success btn-rounded btn-sm">{$menu_nums}</button>
                    </a></li>
                    <li class="{$menuChild?='active'}"><a href="#tab-second" role="tab" data-toggle="tab">菜单添加</a></li>
                </ul>
                <div class="panel-body tab-content">
                    <div class="tab-pane {$menuChild?:'active'}" id="tab-first">
                        <table  class="demo1 table datatable table-hover">
                            <thead>
                            <tr>
                                <th>菜单名称</th>
                                <th>功能结构</th>
                                <!--<th>类型</th>-->
                                <th>状态</th>
                                <th>图标</th>
                                <th>排序</th>
                                <th></th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name='menu_list' id='v'}
                            <tr class="del_tr">
                                <td>{$v.lefthtml}{:menu_type($v.name,$v.type)}</td>
                                <td>@{$v.module}/{$v.controller}/{$v.method}</td>
                                <td>{:is_stop($v.status)}</td>
                                <td><i class="{$v.icon}"></i></td>
                                <td><input onchange="change_order(this)" style="width: 70px" type="number" class="order_change form-control" data-url="{:url('admin/menu/update_order')}" pk-id="{$v.id}" value="{$v.listorder}"></td>
                                <td>
                                    <a href="{:url('admin/Menu/home_page',['menu_id'=>$v.id])}" class="btn btn-primary btn-rounded btn-sm"><span class="fa fa-plus"></span></a>
                                    <a title="{$v['name']}【编辑】" data-url="{:url('admin/Menu/edit_page',['menu_id'=>$v.id])}" onclick="edit_row(this)" class="btn btn-default btn-rounded btn-sm"><span class="fa fa-pencil"></span></a>
                                    <button onClick="delete_row(this);" data-url="{:url('admin/menu/del_think',['id'=>$v.id])}" class="btn btn-danger btn-rounded btn-sm" ><span class="fa fa-trash-o"></span></button>
                                </td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                    </div>
                    <div class="tab-pane {$menuChild?='active'}" id="tab-second">
                        <form id="add_form" action="{:url('admin/menu/add_think')}" method="post" class="form-horizontal">
                            <div class="alert alert-info" role="alert">
                                <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                <strong>温馨提醒!</strong> 如果添加菜单没有控制器、方法,统一填写<span class="label label-default">default</span>
                            </div>
                            <div class="panel-body">
                                <div class="row">
                                    <div class="col-md-9">
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">父级菜单</label>
                                            <div class="col-md-9">
                                                <select name="parentid" class="form-control select">
                                                    <option  value="">作为父级</option>
                                                    {volist name='menu_list' id='v'}
                                                    {notempty name='$menuChild'}
                                                        <option {:is_selected($menuChild,$v.id)} value="{$v.id}">{$v.lefthtml}{$v.name}</option>
                                                     {else/}
                                                         <option  value="{$v.id}">{$v.lefthtml}{$v.name}</option>
                                                    {/notempty}
                                                    {/volist}
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">菜单名称</label>
                                            <div class="col-md-9">
                                                <input name="name" type="text" class="form-control"/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">@模块/控制器/方法</label>
                                            <div class="col-md-3">
                                               <input name="module" type="text" value="admin" class="form-control"/>
                                            </div>
                                            <div class="col-md-3">
                                                <select name="controller" class="form-control select">
                                                    <option  value="Default">Default</option>
                                                    {volist name='controller' id='v'}
                                                    <option value="{:basename($v.filename,'.php')}">{:basename($v.filename,'.php')}</option>
                                                    {/volist}
                                                </select>
                                            </div>
                                            <div class="col-md-3">
                                                <input name="method" type="text" value="" class="form-control"/>
                                                <span class="help-block">默认填default</span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="col-md-3 control-label">菜单徽标</div>
                                            <div class="col-md-9">
                                                <input name="icon" type="text" class="form-control"/>
                                                <span class="help-block">格式:fa fa-users</span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">备注</label>
                                            <div class="col-md-9 col-xs-12">
                                                <textarea name="remark" class="form-control" rows="5"></textarea>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">菜单类型</label>
                                            <div class="col-md-9">
                                                <select name="type" class="form-control select">
                                                    <option value="0">菜单</option>
                                                    <option value="1">权限认证</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3  control-label">菜单状态</label>
                                            <div class="col-md-9">
                                                <label class="switch">
                                                    <input name="status" type="checkbox" checked value="1"/>
                                                    <span></span>
                                                </label>
                                                <span class="help-block">默认正常</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="panel-footer">
                                <button class="btn btn-info pull-right">保存添加<span class="fa fa-floppy-o fa-right"></span></button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $('.demo1').dataTable({
        order:[]
    });
    function change_order(dom) {
        $.post($(dom).attr('data-url'),{
            id:$(dom).attr('pk-id'),
            listorder:$(dom).val()
        },function (res) {
            destory();
            if(res.code){
                m_success(res.msg)
            }else{
                m_error(res.msg)
            }
        })
    }
</script>
{/block}